#pragma once

// default is getthis.ddns.net
#ifndef __DEFAULT_ADDRESS__
#define __DEFAULT_ADDRESS__ "getthis.ddns.net"
#endif  // __DEFAULT_ADDRESS__

// default is .\\Configuration.ini
#ifndef __DEFAULT_PORT__
#if _LOCAL_DEBUG
#define __DEFAULT_PORT__ "27761"
#else
#define __DEFAULT_PORT__ "27167"
#endif
#endif  // __DEFAULT_PORT__

// default is .\\Configuration.ini
#ifndef __CONFIGURATION_INI_PATH__
#define __CONFIGURATION_INI_PATH__ ".\\Configuration.ini"
#endif  // __CONFIGURATION_INI_PATH__

// default is 500ms
#ifndef __SUSPENSE_DURATION__
#define __SUSPENSE_DURATION__ 500
#endif  // __SUSPENSE_DURATION__

// default is 5000ms
#ifndef __CHECK_CONNECTION_INTERVAL__
#define __CHECK_CONNECTION_INTERVAL__ 5000
#endif  // __CHECK_CONNECTION_INTERVAL__

// Command line switch to updated application
#ifndef __APPLICATION_UPDATED__
#define __APPLICATION_UPDATED__	" --Update"
#endif

// Command line switch for restarted application
#ifndef __APPLICATION_RESTARTED__
#define __APPLICATION_RESTARTED__	" --Restart"
#endif

// 1 to show warnings
#ifndef __SHOW_WARNINGS__
#define __SHOW_WARNINGS__ 1
#endif  // __SHOW_WARNINGS__

// 1 to show informations
#ifndef __SHOW_INFORMATIONS__
#define __SHOW_INFORMATIONS__ 0
#endif  // __SHOW_INFORMATIONS__

#ifndef __COMMON_H__
#define __COMMON_H__

#include "targetver.h"
#include <tchar.h>
#include <winsock2.h>
#include <windows.h>
#include <string>
#include <locale>
#include <codecvt>
#include <vector>

using namespace std;

const int BOOL_SIZE = sizeof(bool);
const int UNSIGNED_INT_SIZE = sizeof(unsigned int);
const int INT_SIZE = sizeof(int);
const int DOUBLE_SIZE = sizeof(double);

#define _W(x) Common::Widen(x)
#define _N(x) Common::Narrow(x)

// Helper for connection operations.
class Common
{
public:
	// Convert from UTF-8 to UTF-16.
	static wstring Widen(const char* source);

	// Convert from UTF-8 to UTF-16.
	static wstring Widen(const string& source);

	// Convert from UTF-16 to UTF-8.
	static string Narrow(const wchar_t* source);

	// Convert from UTF-16 to UTF-8.
	static string Narrow(const wstring& source);
};

#endif  // __COMMON_H__